﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace DC2010_Editor
{
public static class CrystalPaint
{
    // Fields
    private const float aaaa = 0.39f;

    // Methods
    internal static Color a(Color A_0, Color A_1, float A_2)
    {
        byte red = Convert.ToByte((float) (A_0.R + ((A_1.R - A_0.R) * A_2)));
        byte green = Convert.ToByte((float) (A_0.G + ((A_1.G - A_0.G) * A_2)));
        byte blue = Convert.ToByte((float) (A_0.B + ((A_1.B - A_0.B) * A_2)));
        return Color.FromArgb(Convert.ToByte((float) (A_0.A + ((A_1.A - A_0.A) * A_2))), red, green, blue);
    }

    internal static void a(Graphics A_0, Color A_1, RectangleF A_2, double A_3)
    {
        b.a a = b.aa(A_1);
        a.b(a.b() + (a.b() * 0.5));
        Color baseColor = b.aa(a);
        using (Pen pen = new Pen(Color.FromArgb((int) (150.0 * A_3), baseColor), 1f))
        {
            A_0.DrawRectangle(pen, (float) (A_2.X + 1f), (float) (A_2.Y + 1f), (float) (A_2.Width - 3f), (float) (A_2.Height - 2f));
        }
        b.a a2 = b.aa(A_1);
        a2.c(a2.aaa() - (a2.aaa() * 0.5));
        Color color2 = b.aa(a2);
        using (Pen pen2 = new Pen(Color.FromArgb((int) (255.0 * A_3), color2), 1f))
        {
            A_0.DrawLine(pen2, A_2.X + 1f, A_2.Y, A_2.Right - 2f, A_2.Y);
            A_0.DrawLine(pen2, (float) (A_2.X + 1f), (float) (A_2.Bottom - 1f), (float) (A_2.Right - 2f), (float) (A_2.Bottom - 1f));
            A_0.DrawLine(pen2, A_2.X, A_2.Y + 1f, A_2.X, A_2.Bottom - 2f);
            A_0.DrawLine(pen2, (float) (A_2.Right - 1f), (float) (A_2.Y + 1f), (float) (A_2.Right - 1f), (float) (A_2.Bottom - 2f));
        }
    }

    internal static void a(Graphics A_0, Color A_1, Color A_2, RectangleF A_3, double A_4)
    {
        new RectangleF(A_3.X + 1f, A_3.Y, A_3.Width - 2f, 3f);
        using (LinearGradientBrush brush = new LinearGradientBrush(A_3, Color.FromArgb(200, 120, 120, 120), Color.FromArgb(200, 200, 200, 200), LinearGradientMode.Vertical))
        {
            using (Pen pen = new Pen(brush))
            {
                A_0.DrawLine(pen, A_3.X, A_3.Y + 1f, A_3.X, A_3.Bottom - 3f);
                A_0.DrawLine(pen, (float) (A_3.Right - 1f), (float) (A_3.Y + 1f), (float) (A_3.Right - 1f), (float) (A_3.Bottom - 3f));
            }
        }
        using (Pen pen2 = new Pen(Color.FromArgb(150, A_2), 2f))
        {
            A_0.DrawLine(pen2, (float) (A_3.X + 2f), (float) (A_3.Y + 1f), (float) (A_3.X + 2f), (float) (A_3.Bottom - 1f));
            A_0.DrawLine(pen2, (float) (A_3.Right - 2f), (float) (A_3.Y + 1f), (float) (A_3.Right - 2f), (float) (A_3.Bottom - 1f));
            A_0.DrawLine(pen2, (float) (A_3.X + 1f), (float) (A_3.Bottom - 1f), (float) (A_3.Right - 1f), (float) (A_3.Bottom - 1f));
        }
        Color baseColor = Color.FromArgb(130, 130, 130);
        using (Pen pen3 = new Pen(A_1))
        {
            A_0.DrawLine(pen3, A_3.X + 1f, A_3.Y, A_3.Right - 2f, A_3.Y);
        }
        using (Pen pen4 = new Pen(Color.FromArgb(170, baseColor)))
        {
            A_0.DrawLine(pen4, A_3.X + 1f, A_3.Y, A_3.Right - 2f, A_3.Y);
        }
        using (Pen pen5 = new Pen(Color.FromArgb(60, baseColor)))
        {
            A_0.DrawLine(pen5, (float) (A_3.X + 1f), (float) (A_3.Y + 1f), (float) (A_3.Right - 2f), (float) (A_3.Y + 1f));
            A_0.DrawLine(pen5, (float) (A_3.X + 1f), (float) (A_3.Bottom - 1f), (float) (A_3.Right - 2f), (float) (A_3.Bottom - 1f));
        }
        using (Pen pen6 = new Pen(Color.FromArgb(30, baseColor)))
        {
            A_0.DrawLine(pen6, (float) (A_3.X + 1f), (float) (A_3.Y + 2f), (float) (A_3.Right - 2f), (float) (A_3.Y + 2f));
        }
    }

    public static Image CreateDisabledImage(Image image)
    {
        return ToolStripRenderer.CreateDisabledImage(image);
    }

    public static void DrawButtonHighlight(Graphics g, Color baseColor, Color pushedBaseColor, RectangleF bounds, RenderMode renderMode, float opacity)
    {
        RectangleF ef = new RectangleF(bounds.X, bounds.Y + 1f, bounds.Width, bounds.Height - 2f);
        DrawHighlight(g, baseColor, pushedBaseColor, ef, renderMode, opacity);
        a(g, baseColor, bounds, (double) opacity);
    }

    public static void DrawHighlight(Graphics g, Color baseColor, Color pushedBaseColor, RectangleF bounds, RenderMode renderMode, float opacity)
    {
        //a.b();
        g.SmoothingMode = (renderMode == RenderMode.HighQuality) ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed;
        using (Brush brush = new SolidBrush(Color.FromArgb((int) (opacity * baseColor.A), baseColor)))
        {
            g.FillRectangle(brush, bounds);
        }
        b.a a = b.aa(baseColor);
        a.aaa(a.c() + 0.027450980392156862);
        a.b(a.b() + (a.b() * 0.40000000596046448));
        Color color = b.aa(a);
        RectangleF rect = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height * 0.39f);
        RectangleF ef2 = new RectangleF(bounds.X, bounds.Y - 1f, bounds.Width, (bounds.Height * 0.39f) + 1f);
        using (LinearGradientBrush brush2 = new LinearGradientBrush(ef2, Color.FromArgb((int) (color.A * opacity), color), Color.FromArgb((int) (127f * opacity), color), LinearGradientMode.Vertical))
        {
            Blend blend = new Blend(3);
            blend.Positions[0] = 0f;
            blend.Positions[1] = 0.65f;
            blend.Positions[2] = 1f;
            blend.Factors[0] = 0f;
            blend.Factors[1] = 0.45f;
            blend.Factors[2] = 1f;
            brush2.Blend = blend;
            g.FillRectangle(brush2, rect);
        }
        a.aaa(a.c() - 0.047058823529411764);
        Color color2 = b.aa(a);
        RectangleF ef3 = new RectangleF(bounds.X, rect.Bottom, bounds.Width, bounds.Height * 0.61f);
        RectangleF ef4 = new RectangleF(bounds.X, rect.Bottom - 1f, bounds.Width, (bounds.Height * 0.61f) + 2f);
        switch (renderMode)
        {
            case RenderMode.HighQuality:
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(ef4.X - 50f, ef4.Y, ef4.Width + 100f, ef4.Height * 2f);
                    using (PathGradientBrush brush3 = new PathGradientBrush(path))
                    {
                        brush3.CenterColor = Color.FromArgb((int) (215f * opacity), color2);
                        brush3.SurroundColors = new Color[] { Color.Transparent };
                        g.FillRectangle(brush3, ef3);
                    }
                    return;
                }
            }
            case RenderMode.HighSpeed:
                using (LinearGradientBrush brush4 = new LinearGradientBrush(ef4, Color.Transparent, Color.FromArgb((int) (215f * opacity), color2), LinearGradientMode.Vertical))
                {
                    Blend blend2 = new Blend(3);
                    blend2.Positions[0] = 0f;
                    blend2.Positions[1] = 0.65f;
                    blend2.Positions[2] = 1f;
                    blend2.Factors[0] = 0f;
                    blend2.Factors[1] = 0.5f;
                    blend2.Factors[2] = 1f;
                    brush4.Blend = blend2;
                    g.FillRectangle(brush4, ef3);
                }
                return;

            default:
                return;
        }
    }

    public static void DrawPushedButtonHighlight(Graphics g, Color baseColor, Color highlightBaseColor, RenderMode renderMode, RectangleF bounds, float opacity)
    {
        RectangleF ef = new RectangleF(bounds.X, bounds.Y + 1f, bounds.Width, bounds.Height - 2f);
        DrawPushedHighlight(g, baseColor, highlightBaseColor, ef, renderMode, opacity);
        a(g, baseColor, highlightBaseColor, bounds, (double) opacity);
    }

    public static void DrawPushedHighlight(Graphics g, Color baseColor, Color highlightBaseColor, RectangleF bounds, RenderMode renderMode, float opacity)
    {
        //a.b();
        g.SmoothingMode = (renderMode == RenderMode.HighQuality) ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed;
        b.a a = b.aa(baseColor);
        a.b(a.b() - (a.b() * (0.1f * opacity)));
        baseColor = b.aa(a);
        using (Brush brush = new SolidBrush(baseColor))
        {
            g.FillRectangle(brush, bounds);
        }
        b.a a2 = b.aa(baseColor);
        a2.aaa(a2.c() + 0.00784313725490196);
        a2.b(a2.b() + (a2.b() * 0.550000011920929));
        Color color = b.aa(a2);
        RectangleF rect = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height * 0.39f);
        RectangleF ef2 = new RectangleF(bounds.X, bounds.Y - 1f, bounds.Width, (bounds.Height * 0.39f) + 2f);
        using (LinearGradientBrush brush2 = new LinearGradientBrush(ef2, color, Color.FromArgb(80, color), LinearGradientMode.Vertical))
        {
            Blend blend = new Blend(3);
            blend.Positions[0] = 0f;
            blend.Positions[1] = 0.45f;
            blend.Positions[2] = 1f;
            blend.Factors[0] = 0f;
            blend.Factors[1] = 0.55f;
            blend.Factors[2] = 1f;
            brush2.Blend = blend;
            g.FillRectangle(brush2, rect);
        }
        b.a a3 = b.aa(highlightBaseColor);
        a3.b(a3.b() + (a3.b() * 0.30000001192092896));
        a3.aaa(a3.c() + 0.027777777777777776);
        Color color2 = b.aa(a3);
        RectangleF ef3 = new RectangleF(bounds.X, rect.Bottom, bounds.Width, bounds.Height * 0.61f);
        RectangleF ef4 = new RectangleF(bounds.X, rect.Bottom - 1f, bounds.Width, (bounds.Height * 0.61f) + 1f);
        switch (renderMode)
        {
            case RenderMode.HighQuality:
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(ef4.X - 50f, ef4.Y, ef4.Width + 100f, ef4.Height * 2f);
                    using (PathGradientBrush brush3 = new PathGradientBrush(path))
                    {
                        ColorBlend blend2 = new ColorBlend(2);
                        float[] numArray = new float[3];
                        numArray[1] = 0.2f;
                        numArray[2] = 1f;
                        blend2.Positions = numArray;
                        blend2.Colors = new Color[] { Color.Transparent, Color.FromArgb((int) (50f * (1f - opacity)), color2), Color.FromArgb(160 + ((int) (80f * (1f - opacity))), color2) };
                        brush3.InterpolationColors = blend2;
                        g.FillRectangle(brush3, ef3);
                    }
                    return;
                }
            }
            case RenderMode.HighSpeed:
                using (LinearGradientBrush brush4 = new LinearGradientBrush(ef4, Color.FromArgb((int) (30f * (1f - opacity)), color2), Color.FromArgb(160 + ((int) (80f * (1f - opacity))), color2), LinearGradientMode.Vertical))
                {
                    Blend blend3 = new Blend(3);
                    blend3.Positions[0] = 0f;
                    blend3.Positions[1] = 0.5f;
                    blend3.Positions[2] = 1f;
                    blend3.Factors[0] = 0f;
                    blend3.Factors[1] = 0.5f;
                    blend3.Factors[2] = 1f;
                    brush4.Blend = blend3;
                    g.FillRectangle(brush4, ef3);
                }
                return;

            default:
                return;
        }
    }

    public static void DrawStringDisabled(Graphics g, string text, Font font, Color foreColor, RectangleF rectangle, StringFormat sf)
    {
        int red = 100 + ((int) (80f * foreColor.GetBrightness()));
        using (SolidBrush brush = new SolidBrush(Color.FromArgb(0x7f, red, red, red)))
        {
            g.DrawString(text, font, brush, rectangle, sf);
        }
    }

    public static Rectangle OffsetRectangle(Rectangle rect, Point offset)
    {
        return new Rectangle(rect.X + offset.X, rect.Y + offset.Y, rect.Width, rect.Height);
    }

    public static Rectangle ResizeRectangle(Rectangle rect, int s)
    {
        return ResizeRectangle(rect, s, s);
    }

    public static Rectangle ResizeRectangle(Rectangle rect, int w, int h)
    {
        return new Rectangle(rect.X, rect.Y, rect.Width + w, rect.Height + h);
    }

    // Nested Types
    public enum RenderMode
    {
        HighQuality,
        HighSpeed
    }
}
 

}
